using MongoDB.Bson;
using Sustainalytics.Entities;
using Sustainalytics.Entities.ESGRatings;
using System;
using System.Collections.Generic;
using Sustainalytics.Entities.RiskRatings;

namespace Sustainalytics.DataLayer
{
    public interface ICompanyScreeningRepository
    {
        TemplateCriteria GetTemplateCriteriaById(Guid templateCriteriaId);
        FilterCriteria GetFilterCriteria(Guid filterId, Guid templateCriteriaId);
        int GetLastCountForFilterCriteria(Guid filterId);
        void AddFilterCriteria(FilterCriteria filterCriteria);
        void UpdateFilterCriteria(FilterCriteria filterCriteria);

        CriteriaLevel1 GetCriteriaLevelOne(Guid criteriaLevel1Id);
        CriteriaLevel2 GetCriteriaLevelTwo(Guid criteriaLevel2Id);
        CriteriaLevel2 GetCriteriaLevelTwoByLevel3Id(Guid criteriaLevel3Id);
        CriteriaLevel3 GetCriteriaLevelThree(Guid criteriaLevel3Id);

        T LoadTemplateCriteria<T>(Guid id) where T : IEntity;

        CriteriaTypeThree LoadCriteriaTypeThreeSingleCollection(string collectionName);
        List<CriteriaTypeFour> LoadCriteriaTypeFour(Guid PIFilterCriteriaId);
        CriteriaType16 LoadCriteriaType16(Guid criteriaTemplateId);

        List<CriteriaLevel1> ListCriteriaLevelOne();
        List<CriteriaLevel2> ListCriteriaLevelTwo(Guid? criteriaLevel1Id);
        List<BaseCriteria> ListBaseCriteria(Guid? criteriaLevel2Id);

        void UpdateSelectedCriteriaOrderNumber(Guid filterId, List<Guid> criteriaIds);
        List<CriteriaLevel2> ListFeatureUniversesByCriteriaLevelTwoId(List<Guid> criteriaLevel2Id);
       
        void SaveResultOutput(Guid filterId, BsonArray resultOutput);
        List<CriteriaResultOutput> GetResultOutputByFilterId(Guid filterId);
        List<BsonDocument> GetResultOutput(ResultOutputFilter filter, int skip, int take, string[] orderBy = null, bool asc = true);
        int CountResultOutput(ResultOutputFilter filter);
        List<BsonDocument> GetFullResultOutput(ResultOutputFilter filter);
        void DeleteResultOutput(Guid filterId);

        List<TemplateCriteria> ListTemplateCriteriaByLevel3Id(Guid? criteriaLevel3Id);
        List<TemplateCriteria> GetDataPointsByCriteriaLevel2Id(Guid criteriaLevel2Id);
        List<TemplateCriteria> ListTemplateCriteria();
        Guid GetTemplateCriteriaIdByPISymbol(string piSymbol);

        List<FilterCriteria> GetFilterCriteriasByFilterId(Guid filterId);
        string[] GetFieldsForFilterCriteria(Guid filterId);
        Filter GetFilterByFilterId(Guid filterId);
        ESGProfile GetDefaultProfile();
        void PublishStandardFilters();
        string GetAccountNameForFtpReportByAccountId(Guid accountId);
        List<Filter> GetAllFilters();
        void UpdateFilter(Guid filterId, int newUniverseId);
        void DuplicateFiltersCollection();
        void CleanUpOldFiltersCollection();

        List<RiskRatingCluster> GetRiskRatingClusters_Mei();
        List<RiskRatingCluster> GetRiskRatingClusters_Overall();
        string GetRiskRatingAnswerCategoryText(TemplateCriteria criteria, int value);
    }
}
